public class Semaphore {
    private String name;
    private int value;
    private PCB waitPCB;
    //最后一个FCB
    private PCB tailPCB;

    public Semaphore(String name, int value) {
        this.name = name;
        this.value = value;
    }

    public int getValue() {
        return value;
    }

    public void valueReduce() {
        this.value--;
    }

    public void linkNewProcess(Process newProcess) {
        if (tailPCB != null) {
            newProcess.getPCB().setPrevPCB(tailPCB);
            tailPCB.setNextPCB(newProcess.getPCB());
        }
        tailPCB = newProcess.getPCB();
    }
}
